class Solution {
public:
    vector<vector<int>> merge(vector<vector<int>>& arr) {
        int size = arr.size();
        sort(arr.begin(), arr.end());
        vector<vector<int>> ans{arr[0]};
        for(int i = 0; i < size; ++i)
        {
            if(i + 1 < size && arr[i][0] == arr[i + 1][0]) continue;
            if(ans.back()[1] < arr[i][0]) ans.push_back(arr[i]);
            else ans.back()[1] = max(ans.back()[1], arr[i][1]);
        }
        return ans;
    }
};
